package com.roc.steelend.controller;


import com.roc.steelend.controller.vo.returnformat.ReturnMsgForTable;
import com.roc.steelend.pojo.BigAccount;
import com.roc.steelend.pojo.SmallAccount;
import com.roc.steelend.service.SmallAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "账务小类功能接口")
@CrossOrigin
public class SmallAccountController {

    @Autowired
    private SmallAccountService smallAccountService;

    @GetMapping("/v1/smallaccount/find")
    @ApiOperation(value = "查询账务小类",notes = "可带条件")
    public ReturnMsgForTable findSmallAccountData(@ApiParam(value = "now",required = true)Integer now,
                                                  @ApiParam(value = "size",required = true)Integer size,
                                                  @ApiParam(value = "isPayTakeId",required = false)Integer isPayTakeId,
                                                  @ApiParam(value = "bigAccountId",required = false)Integer bigAccountId){

        ReturnMsgForTable returnMsgForTable = new ReturnMsgForTable();
        returnMsgForTable.setTotal(smallAccountService.findSmallAccountDataCount(isPayTakeId,bigAccountId));
        returnMsgForTable.setObjectList(smallAccountService.findSmallAccountData(now,size,isPayTakeId,bigAccountId));
        returnMsgForTable.setCurrenPage(now);
        return returnMsgForTable;
    }

    @GetMapping("/v1/smallaccount/special")
    @ApiOperation(value = "用于展示账务小类选择器接口")
    public List<SmallAccount> findSmallAccountDataSpecial(
            @RequestParam(value = "bigAccountId",required = false)Integer bigAccountId){

        return smallAccountService.findSmallAccountDataSpecial(bigAccountId);
    }

    @GetMapping("/v1/smallaccount/special/two")
    @ApiOperation(value = "用于展示账务小类选择器接口(用于账务查询)")
    public List<SmallAccount> findSmallAccountDataSpecialTwo(
            @RequestParam(value = "isPayTakeId",required = false)Integer isPayTakeId){
        return smallAccountService.findSmallAccountDataSpecialTwo(isPayTakeId);
    }




}
